home *** CD-ROM | disk | FTP | other *** search
- Path: dispatch.news.demon.net!demon!farlight.demon.co.uk
- From: j shipley <jonathan@farlight.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Convert a float to an int ( and round up/down ? )
- Date: Thu, 07 Mar 1996 01:39:23 GMT
- Message-ID: <826162763.17141@farlight.demon.co.uk>
- NNTP-Posting-Host: farlight.demon.co.uk
- X-NNTP-Posting-Host: farlight.demon.co.uk
- X-Mailer: Mozilla 1.1N (Windows; I; 16bit)
- MIME-Version: 1.0
- Content-Transfer-Encoding: 7bit
- Content-Type: text/plain; charset=us-ascii
-
- I am trying to convert a variable of type float to an int.
-
- How can this be done?
-
- I have tried (int) variable
- i.e what I thought a cast was, but it does not work.
-
- Part 2:
-
- Can I round a float up/down to the nearest number?
- Does a cast do the same as using the modulus operator, %? (in this case).
-
-
-
- I am using Borland C 3.1, and A Book On C (Kelly/Pohl) - neither of which
- has informed me.
-
- Thanks for your help.
-
-